using System;
using System.Collections.Generic;
using System.Windows.Forms;
using LiveStock.dataAccess;

namespace LiveStock
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Splash theSplash = new Splash();
            theSplash.Show();
            bool SQLRunning = true;

            //Check if SqlExpress is installed/running
            try
            {
                UsersData.GetUsers();
            }
            catch
            {
                theSplash.Close();
                SQLRunning = false;
                MessageBox.Show("Error: SQL Express is not running or is not installed.\nA running instance SQL Server 2005 Express is required to run LiveStock.\nProgram will now exit.");
            }

            if (SQLRunning)
            {
                System.Threading.Thread.Sleep(4500);
                theSplash.Close();
                try
                {
                    Application.Run(new LoginForm());
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message + "\n\nUncaught exception has occured. LiveStock will now exit. Have a nice day :)");
                }
            }
        }

    }
}